home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / g_quake / chaseroc.zip / ITEMS.QC < prev    next >
Text File  |  1996-09-21  |  40KB  |  2,673 lines

  1. void() W_SetCurrentAmmo;
  2.  
  3. /* ALL LIGHTS SHOULD BE 0 1 0 IN COLOR ALL OTHER ITEMS SHOULD
  4.  
  5. BE .8 .3 .4 IN COLOR */
  6.  
  7.  
  8.  
  9.  
  10.  
  11. void() SUB_regen =
  12.  
  13. {
  14.  
  15.         self.model = self.mdl;          // restore original model
  16.  
  17.         self.solid = SOLID_TRIGGER;     // allow it to be touched again
  18.  
  19.         sound (self, CHAN_VOICE, "items/itembk2.wav", 1, ATTN_NORM);    // play respawn sound
  20.  
  21.         setorigin (self, self.origin);
  22.  
  23. };
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31. /*QUAKED noclass (0 0 0) (-8 -8 -8) (8 8 8)
  32.  
  33. prints a warning message when spawned
  34.  
  35. */
  36.  
  37. void() noclass =
  38.  
  39. {
  40.  
  41.         dprint ("noclass spawned at");
  42.  
  43.         dprint (vtos(self.origin));
  44.  
  45.         dprint ("\n");
  46.  
  47.         remove (self);
  48.  
  49. };
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57. /*
  58.  
  59. ============
  60.  
  61. PlaceItem
  62.  
  63.  
  64.  
  65. plants the object on the floor
  66.  
  67. ============
  68.  
  69. */
  70.  
  71. void() PlaceItem =
  72.  
  73. {
  74.  
  75.         local float     oldz;
  76.  
  77.  
  78.  
  79.         self.mdl = self.model;          // so it can be restored on respawn
  80.  
  81.         self.flags = FL_ITEM;           // make extra wide
  82.  
  83.         self.solid = SOLID_TRIGGER;
  84.  
  85.         self.movetype = MOVETYPE_TOSS;  
  86.  
  87.         self.velocity = '0 0 0';
  88.  
  89.         self.origin_z = self.origin_z + 6;
  90.  
  91.         oldz = self.origin_z;
  92.  
  93.         if (!droptofloor())
  94.  
  95.         {
  96.  
  97.                 dprint ("Bonus item fell out of level at ");
  98.  
  99.                 dprint (vtos(self.origin));
  100.  
  101.                 dprint ("\n");
  102.  
  103.                 remove(self);
  104.  
  105.                 return;
  106.  
  107.         }
  108.  
  109. };
  110.  
  111.  
  112.  
  113. /*
  114.  
  115. ============
  116.  
  117. StartItem
  118.  
  119.  
  120.  
  121. Sets the clipping size and plants the object on the floor
  122.  
  123. ============
  124.  
  125. */
  126.  
  127. void() StartItem =
  128.  
  129. {
  130.  
  131.         self.nextthink = time + 0.2;    // items start after other solids
  132.  
  133.         self.think = PlaceItem;
  134.  
  135. };
  136.  
  137.  
  138. /*
  139.  
  140. =========================================================================
  141.  
  142.  
  143.  
  144. HEALTH BOX
  145.  
  146.  
  147.  
  148. =========================================================================
  149.  
  150. */
  151.  
  152. //
  153.  
  154. // T_Heal: add health to an entity, limiting health to max_health
  155.  
  156. // "ignore" will ignore max_health limit
  157.  
  158. //
  159.  
  160. float (entity e, float healamount, float ignore) T_Heal =
  161.  
  162. {
  163.  
  164.         if (e.health <= 0)
  165.  
  166.                 return 0;
  167.  
  168.         if ((!ignore) && (e.health >= other.max_health))
  169.  
  170.                 return 0;
  171.  
  172.         healamount = ceil(healamount);
  173.  
  174.  
  175.  
  176.         e.health = e.health + healamount;
  177.  
  178.         if ((!ignore) && (e.health >= other.max_health))
  179.  
  180.                 e.health = other.max_health;
  181.  
  182.                 
  183.  
  184.         if (e.health > 250)
  185.  
  186.                 e.health = 250;
  187.  
  188.         return 1;
  189.  
  190. };
  191.  
  192.  
  193.  
  194. /*QUAKED item_health (.3 .3 1) (0 0 0) (32 32 32) rotten megahealth
  195.  
  196. Health box. Normally gives 25 points.
  197.  
  198. Rotten box heals 5-10 points,
  199.  
  200. megahealth will add 100 health, then 
  201.  
  202. rot you down to your maximum health limit, 
  203.  
  204. one point per second.
  205.  
  206. */
  207.  
  208.  
  209.  
  210. float   H_ROTTEN = 1;
  211.  
  212. float   H_MEGA = 2;
  213.  
  214. .float  healamount, healtype;
  215.  
  216. void() health_touch;
  217.  
  218. void() item_megahealth_rot;
  219.  
  220.  
  221.  
  222. void() item_health =
  223.  
  224. {       
  225.  
  226.         self.touch = health_touch;
  227.  
  228.  
  229.  
  230.         if (self.spawnflags & H_ROTTEN)
  231.  
  232.         {
  233.  
  234.                 precache_model("maps/b_bh10.bsp");
  235.  
  236.  
  237.  
  238.                 precache_sound("items/r_item1.wav");
  239.  
  240.                 setmodel(self, "maps/b_bh10.bsp");
  241.  
  242.                 self.noise = "items/r_item1.wav";
  243.  
  244.                 self.healamount = 15;
  245.  
  246.                 self.healtype = 0;
  247.  
  248.         }
  249.  
  250.         else
  251.  
  252.         if (self.spawnflags & H_MEGA)
  253.  
  254.         {
  255.  
  256.                 precache_model("maps/b_bh100.bsp");
  257.  
  258.                 precache_sound("items/r_item2.wav");
  259.  
  260.                 setmodel(self, "maps/b_bh100.bsp");
  261.  
  262.                 self.noise = "items/r_item2.wav";
  263.  
  264.                 self.healamount = 100;
  265.  
  266.                 self.healtype = 2;
  267.  
  268.         }
  269.  
  270.         else
  271.  
  272.         {
  273.  
  274.                 precache_model("maps/b_bh25.bsp");
  275.  
  276.                 precache_sound("items/health1.wav");
  277.  
  278.                 setmodel(self, "maps/b_bh25.bsp");
  279.  
  280.                 self.noise = "items/health1.wav";
  281.  
  282.                 self.healamount = 25;
  283.  
  284.                 self.healtype = 1;
  285.  
  286.         }
  287.  
  288.         setsize (self, '0 0 0', '32 32 56');
  289.  
  290.         StartItem ();
  291.  
  292. };
  293.  
  294.  
  295.  
  296.  
  297. void() health_touch =
  298.  
  299. {
  300.  
  301.         local   float amount;
  302.  
  303.         local   string  s;
  304.  
  305.         
  306.  
  307.         if (other.classname != "player")
  308.  
  309.                 return;
  310.  
  311.         
  312.  
  313.         if (self.healtype == 2) // Megahealth?  Ignore max_health...
  314.  
  315.         {
  316.  
  317.                 if (other.health >= 250)
  318.  
  319.                         return;
  320.  
  321.                 if (!T_Heal(other, self.healamount, 1))
  322.  
  323.                         return;
  324.  
  325.         }
  326.  
  327.         else
  328.  
  329.         {
  330.  
  331.                 if (!T_Heal(other, self.healamount, 0))
  332.  
  333.                         return;
  334.  
  335.         }
  336.  
  337.         
  338.  
  339.         sprint(other, "You receive ");
  340.  
  341.         s = ftos(self.healamount);
  342.  
  343.         sprint(other, s);
  344.  
  345.         sprint(other, " health\n");
  346.  
  347.         
  348.  
  349. // health touch sound
  350.  
  351.         sound(other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
  352.  
  353.  
  354.  
  355.         stuffcmd (other, "bf\n");
  356.  
  357.         
  358.  
  359.         self.model = string_null;
  360.  
  361.         self.solid = SOLID_NOT;
  362.  
  363.  
  364.  
  365.         // Megahealth = rot down the player's super health
  366.  
  367.         if (self.healtype == 2)
  368.  
  369.         {
  370.  
  371.                 other.items = other.items | IT_SUPERHEALTH;
  372.  
  373.                 self.nextthink = time + 5;
  374.  
  375.                 self.think = item_megahealth_rot;
  376.  
  377.                 self.owner = other;
  378.  
  379.         }
  380.  
  381.         else
  382.  
  383.         {
  384.  
  385.                 if (deathmatch != 2)            // deathmatch 2 is the silly old rules
  386.  
  387.                 {
  388.  
  389.                         if (deathmatch)
  390.  
  391.                                 self.nextthink = time + 20;
  392.  
  393.                         self.think = SUB_regen;
  394.  
  395.                 }
  396.  
  397.         }
  398.  
  399.         
  400.  
  401.         activator = other;
  402.  
  403.         SUB_UseTargets();                               // fire all targets / killtargets
  404.  
  405. };      
  406.  
  407.  
  408.  
  409. void() item_megahealth_rot =
  410.  
  411. {
  412.  
  413.         other = self.owner;
  414.  
  415.         
  416.  
  417.         if (other.health > other.max_health)
  418.  
  419.         {
  420.  
  421.                 other.health = other.health - 1;
  422.  
  423.                 self.nextthink = time + 1;
  424.  
  425.                 return;
  426.  
  427.         }
  428.  
  429.  
  430.  
  431. // it is possible for a player to die and respawn between rots, so don't
  432.  
  433. // just blindly subtract the flag off
  434.  
  435.         other.items = other.items - (other.items & IT_SUPERHEALTH);
  436.  
  437.         
  438.  
  439.         if (deathmatch == 1)    // deathmatch 2 is silly old rules
  440.  
  441.         {
  442.  
  443.                 self.nextthink = time + 20;
  444.  
  445.                 self.think = SUB_regen;
  446.  
  447.         }
  448.  
  449. };
  450.  
  451.  
  452. /*
  453.  
  454. ===============================================================================
  455.  
  456.  
  457.  
  458. ARMOR
  459.  
  460.  
  461.  
  462. ===============================================================================
  463.  
  464. */
  465.  
  466.  
  467.  
  468. void() armor_touch;
  469.  
  470.  
  471.  
  472. void() armor_touch =
  473.  
  474. {
  475.  
  476.         local   float   type, value, bit;
  477.  
  478.         
  479.  
  480.         if (other.health <= 0)
  481.  
  482.                 return;
  483.  
  484.         if (other.classname != "player")
  485.  
  486.                 return;
  487.  
  488.  
  489.  
  490.         if (self.classname == "item_armor1")
  491.  
  492.         {
  493.  
  494.                 type = 0.3;
  495.  
  496.                 value = 100;
  497.  
  498.                 bit = IT_ARMOR1;
  499.  
  500.         }
  501.  
  502.         if (self.classname == "item_armor2")
  503.  
  504.         {
  505.  
  506.                 type = 0.6;
  507.  
  508.                 value = 150;
  509.  
  510.                 bit = IT_ARMOR2;
  511.  
  512.         }
  513.  
  514.         if (self.classname == "item_armorInv")
  515.  
  516.         {
  517.  
  518.                 type = 0.8;
  519.  
  520.                 value = 200;
  521.  
  522.                 bit = IT_ARMOR3;
  523.  
  524.         }
  525.  
  526.         if (other.armortype*other.armorvalue >= type*value)
  527.  
  528.                 return;
  529.  
  530.                 
  531.  
  532.         other.armortype = type;
  533.  
  534.         other.armorvalue = value;
  535.  
  536.         other.items = other.items - (other.items & (IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + bit;
  537.  
  538.  
  539.  
  540.         self.solid = SOLID_NOT;
  541.  
  542.         self.model = string_null;
  543.  
  544.         if (deathmatch == 1)
  545.  
  546.                 self.nextthink = time + 20;
  547.  
  548.         self.think = SUB_regen;
  549.  
  550.  
  551.  
  552.         sprint(other, "You got armor\n");
  553.  
  554. // armor touch sound
  555.  
  556.         sound(other, CHAN_ITEM, "items/armor1.wav", 1, ATTN_NORM);
  557.  
  558.         stuffcmd (other, "bf\n");
  559.  
  560.         
  561.  
  562.         activator = other;
  563.  
  564.         SUB_UseTargets();                               // fire all targets / killtargets
  565.  
  566. };
  567.  
  568.  
  569.  
  570.  
  571.  
  572. /*QUAKED item_armor1 (0 .5 .8) (-16 -16 0) (16 16 32)
  573.  
  574. */
  575.  
  576.  
  577.  
  578. void() item_armor1 =
  579.  
  580. {
  581.  
  582.         self.touch = armor_touch;
  583.  
  584.         precache_model ("progs/armor.mdl");
  585.  
  586.         setmodel (self, "progs/armor.mdl");
  587.  
  588.         self.skin = 0;
  589.  
  590.         setsize (self, '-16 -16 0', '16 16 56');
  591.  
  592.         StartItem ();
  593.  
  594. };
  595.  
  596.  
  597.  
  598. /*QUAKED item_armor2 (0 .5 .8) (-16 -16 0) (16 16 32)
  599.  
  600. */
  601.  
  602.  
  603.  
  604. void() item_armor2 =
  605.  
  606. {
  607.  
  608.         self.touch = armor_touch;
  609.  
  610.         precache_model ("progs/armor.mdl");
  611.  
  612.         setmodel (self, "progs/armor.mdl");
  613.  
  614.         self.skin = 1;
  615.  
  616.         setsize (self, '-16 -16 0', '16 16 56');
  617.  
  618.         StartItem ();
  619.  
  620. };
  621.  
  622.  
  623.  
  624. /*QUAKED item_armorInv (0 .5 .8) (-16 -16 0) (16 16 32)
  625.  
  626. */
  627.  
  628.  
  629.  
  630. void() item_armorInv =
  631.  
  632. {
  633.  
  634.         self.touch = armor_touch;
  635.  
  636.         precache_model ("progs/armor.mdl");
  637.  
  638.         setmodel (self, "progs/armor.mdl");
  639.  
  640.         self.skin = 2;
  641.  
  642.         setsize (self, '-16 -16 0', '16 16 56');
  643.  
  644.         StartItem ();
  645.  
  646. };
  647.  
  648.  
  649.  
  650. /*
  651.  
  652. ===============================================================================
  653.  
  654.  
  655.  
  656. WEAPONS
  657.  
  658.  
  659.  
  660. ===============================================================================
  661.  
  662. */
  663.  
  664.  
  665.  
  666. void() bound_other_ammo =
  667.  
  668. {
  669.  
  670.         if (other.ammo_shells > 100)
  671.  
  672.                 other.ammo_shells = 100;
  673.  
  674.         if (other.ammo_nails > 200)
  675.  
  676.                 other.ammo_nails = 200;
  677.  
  678.         if (other.ammo_rockets > 100)
  679.  
  680.                 other.ammo_rockets = 100;               
  681.  
  682.         if (other.ammo_cells > 100)
  683.  
  684.                 other.ammo_cells = 100;         
  685.  
  686. };
  687.  
  688.  
  689.  
  690.  
  691.  
  692. float(float w) RankForWeapon =
  693.  
  694. {
  695.  
  696.         if (w == IT_LIGHTNING)
  697.  
  698.                 return 1;
  699.  
  700.         if (w == IT_ROCKET_LAUNCHER)
  701.  
  702.                 return 2;
  703.  
  704.         if (w == IT_SUPER_NAILGUN)
  705.  
  706.                 return 3;
  707.  
  708.         if (w == IT_GRENADE_LAUNCHER)
  709.  
  710.                 return 4;
  711.  
  712.         if (w == IT_SUPER_SHOTGUN)
  713.  
  714.                 return 5;
  715.  
  716.         if (w == IT_NAILGUN)
  717.  
  718.                 return 6;
  719.  
  720.         return 7;
  721.  
  722. };
  723.  
  724.  
  725.  
  726. /*
  727.  
  728. =============
  729.  
  730. Deathmatch_Weapon
  731.  
  732.  
  733.  
  734. Deathmatch weapon change rules for picking up a weapon
  735.  
  736.  
  737.  
  738. .float          ammo_shells, ammo_nails, ammo_rockets, ammo_cells;
  739.  
  740. =============
  741.  
  742. */
  743.  
  744. void(float old, float new) Deathmatch_Weapon =
  745.  
  746. {
  747.  
  748.         local float or, nr;
  749.  
  750.  
  751.  
  752. // change self.weapon if desired
  753.  
  754.         or = RankForWeapon (self.weapon);
  755.  
  756.         nr = RankForWeapon (new);
  757.  
  758.         if ( nr < or )
  759.  
  760.                 self.weapon = new;
  761.  
  762. };
  763.  
  764.  
  765.  
  766. /*
  767.  
  768. =============
  769.  
  770. weapon_touch
  771.  
  772. =============
  773.  
  774. */
  775.  
  776. float() W_BestWeapon;
  777.  
  778.  
  779.  
  780. void() weapon_touch =
  781.  
  782. {
  783.  
  784.         local   float   hadammo, best, new, old;
  785.  
  786.         local   entity  stemp;
  787.  
  788.         local   float   leave;
  789.  
  790.  
  791.  
  792.         if (!(other.flags & FL_CLIENT))
  793.  
  794.                 return;
  795.  
  796.  
  797.  
  798. // if the player was using his best weapon, change up to the new one if better          
  799.  
  800.         stemp = self;
  801.  
  802.         self = other;
  803.  
  804.         best = W_BestWeapon();
  805.  
  806.         self = stemp;
  807.  
  808.  
  809.  
  810.         if (deathmatch == 2 || coop)
  811.  
  812.                 leave = 1;
  813.  
  814.         else
  815.  
  816.                 leave = 0;
  817.  
  818.         
  819.  
  820.         if (self.classname == "weapon_nailgun")
  821.  
  822.         {
  823.  
  824.                 if (leave && (other.items & IT_NAILGUN) )
  825.  
  826.                         return;
  827.  
  828.                 hadammo = other.ammo_nails;                     
  829.  
  830.                 new = IT_NAILGUN;
  831.  
  832.                 other.ammo_nails = other.ammo_nails + 30;
  833.  
  834.         }
  835.  
  836.         else if (self.classname == "weapon_supernailgun")
  837.  
  838.         {
  839.  
  840.                 if (leave && (other.items & IT_SUPER_NAILGUN) )
  841.  
  842.                         return;
  843.  
  844.                 hadammo = other.ammo_rockets;                   
  845.  
  846.                 new = IT_SUPER_NAILGUN;
  847.  
  848.                 other.ammo_nails = other.ammo_nails + 30;
  849.  
  850.         }
  851.  
  852.         else if (self.classname == "weapon_supershotgun")
  853.  
  854.         {
  855.  
  856.                 if (leave && (other.items & IT_SUPER_SHOTGUN) )
  857.  
  858.                         return;
  859.  
  860.                 hadammo = other.ammo_rockets;                   
  861.  
  862.                 new = IT_SUPER_SHOTGUN;
  863.  
  864.                 other.ammo_shells = other.ammo_shells + 5;
  865.  
  866.         }
  867.  
  868.         else if (self.classname == "weapon_rocketlauncher")
  869.  
  870.         {
  871.  
  872.                 if (leave && (other.items & IT_ROCKET_LAUNCHER) )
  873.  
  874.                         return;
  875.  
  876.                 hadammo = other.ammo_rockets;                   
  877.  
  878.                 new = IT_ROCKET_LAUNCHER;
  879.  
  880.                 other.ammo_rockets = other.ammo_rockets + 5;
  881.  
  882.         }
  883.  
  884.         else if (self.classname == "weapon_grenadelauncher")
  885.  
  886.         {
  887.  
  888.                 if (leave && (other.items & IT_GRENADE_LAUNCHER) )
  889.  
  890.                         return;
  891.  
  892.                 hadammo = other.ammo_rockets;                   
  893.  
  894.                 new = IT_GRENADE_LAUNCHER;
  895.  
  896.                 other.ammo_rockets = other.ammo_rockets + 5;
  897.  
  898.         }
  899.  
  900.         else if (self.classname == "weapon_lightning")
  901.  
  902.         {
  903.  
  904.                 if (leave && (other.items & IT_LIGHTNING) )
  905.  
  906.                         return;
  907.  
  908.                 hadammo = other.ammo_rockets;                   
  909.  
  910.                 new = IT_LIGHTNING;
  911.  
  912.                 other.ammo_cells = other.ammo_cells + 15;
  913.  
  914.         }
  915.  
  916.         else
  917.  
  918.                 objerror ("weapon_touch: unknown classname");
  919.  
  920.  
  921.  
  922.         sprint (other, "You got the ");
  923.  
  924.         sprint (other, self.netname);
  925.  
  926.         sprint (other, "\n");
  927.  
  928. // weapon touch sound
  929.  
  930.         sound (other, CHAN_ITEM, "weapons/pkup.wav", 1, ATTN_NORM);
  931.  
  932.         stuffcmd (other, "bf\n");
  933.  
  934.  
  935.  
  936.         bound_other_ammo ();
  937.  
  938.  
  939.  
  940. // change to the weapon
  941.  
  942.         old = other.items;
  943.  
  944.         other.items = other.items | new;
  945.  
  946.         
  947.  
  948.         stemp = self;
  949.  
  950.         self = other;
  951.  
  952.  
  953.  
  954.         if (!deathmatch)
  955.  
  956.                 self.weapon = new;
  957.  
  958.         else
  959.  
  960.                 Deathmatch_Weapon (old, new);
  961.  
  962.  
  963.         W_SetCurrentAmmo();
  964.  
  965.  
  966.  
  967.         self = stemp;
  968.  
  969.  
  970.  
  971.         if (leave)
  972.  
  973.                 return;
  974.  
  975.  
  976.  
  977. // remove it in single player, or setup for respawning in deathmatch
  978.  
  979.         self.model = string_null;
  980.  
  981.         self.solid = SOLID_NOT;
  982.  
  983.         if (deathmatch == 1)
  984.  
  985.                 self.nextthink = time + 30;
  986.  
  987.         self.think = SUB_regen;
  988.  
  989.         
  990.  
  991.         activator = other;
  992.  
  993.         SUB_UseTargets();                               // fire all targets / killtargets
  994.  
  995. };
  996.  
  997.  
  998.  
  999.  
  1000.  
  1001. /*QUAKED weapon_supershotgun (0 .5 .8) (-16 -16 0) (16 16 32)
  1002.  
  1003. */
  1004.  
  1005.  
  1006.  
  1007. void() weapon_supershotgun =
  1008.  
  1009. {
  1010.  
  1011.         precache_model ("progs/g_shot.mdl");
  1012.  
  1013.         setmodel (self, "progs/g_shot.mdl");
  1014.  
  1015.         self.weapon = IT_SUPER_SHOTGUN;
  1016.  
  1017.         self.netname = "Double-barrelled Shotgun";
  1018.  
  1019.         self.touch = weapon_touch;
  1020.  
  1021.         setsize (self, '-16 -16 0', '16 16 56');
  1022.  
  1023.         StartItem ();
  1024.  
  1025. };
  1026.  
  1027.  
  1028.  
  1029. /*QUAKED weapon_nailgun (0 .5 .8) (-16 -16 0) (16 16 32)
  1030.  
  1031. */
  1032.  
  1033.  
  1034.  
  1035. void() weapon_nailgun =
  1036.  
  1037. {
  1038.  
  1039.         precache_model ("progs/g_nail.mdl");
  1040.  
  1041.         setmodel (self, "progs/g_nail.mdl");
  1042.  
  1043.         self.weapon = IT_NAILGUN;
  1044.  
  1045.         self.netname = "nailgun";
  1046.  
  1047.         self.touch = weapon_touch;
  1048.  
  1049.         setsize (self, '-16 -16 0', '16 16 56');
  1050.  
  1051.         StartItem ();
  1052.  
  1053. };
  1054.  
  1055.  
  1056.  
  1057. /*QUAKED weapon_supernailgun (0 .5 .8) (-16 -16 0) (16 16 32)
  1058.  
  1059. */
  1060.  
  1061.  
  1062.  
  1063. void() weapon_supernailgun =
  1064.  
  1065. {
  1066.  
  1067.         precache_model ("progs/g_nail2.mdl");
  1068.  
  1069.         setmodel (self, "progs/g_nail2.mdl");
  1070.  
  1071.         self.weapon = IT_SUPER_NAILGUN;
  1072.  
  1073.         self.netname = "Super Nailgun";
  1074.  
  1075.         self.touch = weapon_touch;
  1076.  
  1077.         setsize (self, '-16 -16 0', '16 16 56');
  1078.  
  1079.         StartItem ();
  1080.  
  1081. };
  1082.  
  1083.  
  1084.  
  1085. /*QUAKED weapon_grenadelauncher (0 .5 .8) (-16 -16 0) (16 16 32)
  1086.  
  1087. */
  1088.  
  1089.  
  1090.  
  1091. void() weapon_grenadelauncher =
  1092.  
  1093. {
  1094.  
  1095.         precache_model ("progs/g_rock.mdl");
  1096.  
  1097.         setmodel (self, "progs/g_rock.mdl");
  1098.  
  1099.         self.weapon = 3;
  1100.  
  1101.         self.netname = "Grenade Launcher";
  1102.  
  1103.         self.touch = weapon_touch;
  1104.  
  1105.         setsize (self, '-16 -16 0', '16 16 56');
  1106.  
  1107.         StartItem ();
  1108.  
  1109. };
  1110.  
  1111.  
  1112.  
  1113. /*QUAKED weapon_rocketlauncher (0 .5 .8) (-16 -16 0) (16 16 32)
  1114.  
  1115. */
  1116.  
  1117.  
  1118.  
  1119. void() weapon_rocketlauncher =
  1120.  
  1121. {
  1122.  
  1123.         precache_model ("progs/g_rock2.mdl");
  1124.  
  1125.         setmodel (self, "progs/g_rock2.mdl");
  1126.  
  1127.         self.weapon = 3;
  1128.  
  1129.         self.netname = "Rocket Launcher";
  1130.  
  1131.         self.touch = weapon_touch;
  1132.  
  1133.         setsize (self, '-16 -16 0', '16 16 56');
  1134.  
  1135.         StartItem ();
  1136.  
  1137. };
  1138.  
  1139.  
  1140.  
  1141.  
  1142.  
  1143. /*QUAKED weapon_lightning (0 .5 .8) (-16 -16 0) (16 16 32)
  1144.  
  1145. */
  1146.  
  1147.  
  1148.  
  1149. void() weapon_lightning =
  1150.  
  1151. {
  1152.  
  1153.         precache_model ("progs/g_light.mdl");
  1154.  
  1155.         setmodel (self, "progs/g_light.mdl");
  1156.  
  1157.         self.weapon = 3;
  1158.  
  1159.         self.netname = "Thunderbolt";
  1160.  
  1161.         self.touch = weapon_touch;
  1162.  
  1163.         setsize (self, '-16 -16 0', '16 16 56');
  1164.  
  1165.         StartItem ();
  1166.  
  1167. };
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173. /*
  1174.  
  1175. ===============================================================================
  1176.  
  1177.  
  1178.  
  1179. AMMO
  1180.  
  1181.  
  1182.  
  1183. ===============================================================================
  1184.  
  1185. */
  1186.  
  1187.  
  1188.  
  1189. void() ammo_touch =
  1190.  
  1191. {
  1192.  
  1193. local entity    stemp;
  1194.  
  1195. local float             best;
  1196.  
  1197.  
  1198.         if (other.classname != "player")
  1199.  
  1200.                 return;
  1201.  
  1202.         if (other.health <= 0)
  1203.  
  1204.                 return;
  1205.  
  1206.  
  1207.  
  1208. // if the player was using his best weapon, change up to the new one if better          
  1209.  
  1210.         stemp = self;
  1211.  
  1212.         self = other;
  1213.  
  1214.         best = W_BestWeapon();
  1215.  
  1216.         self = stemp;
  1217.  
  1218.  
  1219.  
  1220.  
  1221.  
  1222. // shotgun
  1223.  
  1224.         if (self.weapon == 1)
  1225.  
  1226.         {
  1227.  
  1228.                 if (other.ammo_shells >= 100)
  1229.  
  1230.                         return;
  1231.  
  1232.                 other.ammo_shells = other.ammo_shells + self.aflag;
  1233.  
  1234.         }
  1235.  
  1236.  
  1237.  
  1238. // spikes
  1239.  
  1240.         if (self.weapon == 2)
  1241.  
  1242.         {
  1243.  
  1244.                 if (other.ammo_nails >= 200)
  1245.  
  1246.                         return;
  1247.  
  1248.                 other.ammo_nails = other.ammo_nails + self.aflag;
  1249.  
  1250.         }
  1251.  
  1252.  
  1253.  
  1254. //      rockets
  1255.  
  1256.         if (self.weapon == 3)
  1257.  
  1258.         {
  1259.  
  1260.                 if (other.ammo_rockets >= 100)
  1261.  
  1262.                         return;
  1263.  
  1264.                 other.ammo_rockets = other.ammo_rockets + self.aflag;
  1265.  
  1266.         }
  1267.  
  1268.  
  1269.  
  1270. //      cells
  1271.  
  1272.         if (self.weapon == 4)
  1273.  
  1274.         {
  1275.  
  1276.                 if (other.ammo_cells >= 100)
  1277.  
  1278.                         return;
  1279.  
  1280.                 other.ammo_cells = other.ammo_cells + self.aflag;
  1281.  
  1282.         }
  1283.  
  1284.  
  1285.  
  1286.         bound_other_ammo ();
  1287.  
  1288.         
  1289.  
  1290.         sprint (other, "You got the ");
  1291.  
  1292.         sprint (other, self.netname);
  1293.  
  1294.         sprint (other, "\n");
  1295.  
  1296. // ammo touch sound
  1297.  
  1298.         sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM);
  1299.  
  1300.         stuffcmd (other, "bf\n");
  1301.  
  1302.  
  1303.  
  1304. // change to a better weapon if appropriate
  1305.  
  1306.  
  1307.  
  1308.         if ( other.weapon == best )
  1309.  
  1310.         {
  1311.  
  1312.                 stemp = self;
  1313.  
  1314.                 self = other;
  1315.  
  1316.                 self.weapon = W_BestWeapon();
  1317.  
  1318.                 W_SetCurrentAmmo ();
  1319.  
  1320.                 self = stemp;
  1321.  
  1322.         }
  1323.  
  1324.  
  1325.  
  1326. // if changed current ammo, update it
  1327.  
  1328.         stemp = self;
  1329.  
  1330.         self = other;
  1331.  
  1332.         W_SetCurrentAmmo();
  1333.  
  1334.         self = stemp;
  1335.  
  1336.  
  1337.  
  1338. // remove it in single player, or setup for respawning in deathmatch
  1339.  
  1340.         self.model = string_null;
  1341.  
  1342.         self.solid = SOLID_NOT;
  1343.  
  1344.         if (deathmatch == 1)
  1345.  
  1346.                 self.nextthink = time + 30;
  1347.  
  1348.         self.think = SUB_regen;
  1349.  
  1350.  
  1351.  
  1352.         activator = other;
  1353.  
  1354.         SUB_UseTargets();                               // fire all targets / killtargets
  1355.  
  1356. };
  1357.  
  1358.  
  1359.  
  1360.  
  1361.  
  1362.  
  1363.  
  1364.  
  1365.  
  1366. float WEAPON_BIG2 = 1;
  1367.  
  1368.  
  1369.  
  1370. /*QUAKED item_shells (0 .5 .8) (0 0 0) (32 32 32) big
  1371.  
  1372. */
  1373.  
  1374.  
  1375.  
  1376. void() item_shells =
  1377.  
  1378. {
  1379.  
  1380.         self.touch = ammo_touch;
  1381.  
  1382.  
  1383.  
  1384.         if (self.spawnflags & WEAPON_BIG2)
  1385.  
  1386.         {
  1387.  
  1388.                 precache_model ("maps/b_shell1.bsp");
  1389.  
  1390.                 setmodel (self, "maps/b_shell1.bsp");
  1391.  
  1392.                 self.aflag = 40;
  1393.  
  1394.         }
  1395.  
  1396.         else
  1397.  
  1398.         {
  1399.  
  1400.                 precache_model ("maps/b_shell0.bsp");
  1401.  
  1402.                 setmodel (self, "maps/b_shell0.bsp");
  1403.  
  1404.                 self.aflag = 20;
  1405.  
  1406.         }
  1407.  
  1408.         self.weapon = 1;
  1409.  
  1410.         self.netname = "shells";
  1411.  
  1412.         setsize (self, '0 0 0', '32 32 56');
  1413.  
  1414.         StartItem ();
  1415.  
  1416. };
  1417.  
  1418.  
  1419.  
  1420. /*QUAKED item_spikes (0 .5 .8) (0 0 0) (32 32 32) big
  1421.  
  1422. */
  1423.  
  1424.  
  1425.  
  1426. void() item_spikes =
  1427.  
  1428. {
  1429.  
  1430.         self.touch = ammo_touch;
  1431.  
  1432.  
  1433.  
  1434.         if (self.spawnflags & WEAPON_BIG2)
  1435.  
  1436.         {
  1437.  
  1438.                 precache_model ("maps/b_nail1.bsp");
  1439.  
  1440.                 setmodel (self, "maps/b_nail1.bsp");
  1441.  
  1442.                 self.aflag = 50;
  1443.  
  1444.         }
  1445.  
  1446.         else
  1447.  
  1448.         {
  1449.  
  1450.                 precache_model ("maps/b_nail0.bsp");
  1451.  
  1452.                 setmodel (self, "maps/b_nail0.bsp");
  1453.  
  1454.                 self.aflag = 25;
  1455.  
  1456.         }
  1457.  
  1458.         self.weapon = 2;
  1459.  
  1460.         self.netname = "nails";
  1461.  
  1462.         setsize (self, '0 0 0', '32 32 56');
  1463.  
  1464.         StartItem ();
  1465.  
  1466. };
  1467.  
  1468.  
  1469.  
  1470. /*QUAKED item_rockets (0 .5 .8) (0 0 0) (32 32 32) big
  1471.  
  1472. */
  1473.  
  1474.  
  1475.  
  1476. void() item_rockets =
  1477.  
  1478. {
  1479.  
  1480.         self.touch = ammo_touch;
  1481.  
  1482.  
  1483.  
  1484.         if (self.spawnflags & WEAPON_BIG2)
  1485.  
  1486.         {
  1487.  
  1488.                 precache_model ("maps/b_rock1.bsp");
  1489.  
  1490.                 setmodel (self, "maps/b_rock1.bsp");
  1491.  
  1492.                 self.aflag = 10;
  1493.  
  1494.         }
  1495.  
  1496.         else
  1497.  
  1498.         {
  1499.  
  1500.                 precache_model ("maps/b_rock0.bsp");
  1501.  
  1502.                 setmodel (self, "maps/b_rock0.bsp");
  1503.  
  1504.                 self.aflag = 5;
  1505.  
  1506.         }
  1507.  
  1508.         self.weapon = 3;
  1509.  
  1510.         self.netname = "rockets";
  1511.  
  1512.         setsize (self, '0 0 0', '32 32 56');
  1513.  
  1514.         StartItem ();
  1515.  
  1516. };
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522. /*QUAKED item_cells (0 .5 .8) (0 0 0) (32 32 32) big
  1523.  
  1524. */
  1525.  
  1526.  
  1527.  
  1528. void() item_cells =
  1529.  
  1530. {
  1531.  
  1532.         self.touch = ammo_touch;
  1533.  
  1534.  
  1535.  
  1536.         if (self.spawnflags & WEAPON_BIG2)
  1537.  
  1538.         {
  1539.  
  1540.                 precache_model ("maps/b_batt1.bsp");
  1541.  
  1542.                 setmodel (self, "maps/b_batt1.bsp");
  1543.  
  1544.                 self.aflag = 12;
  1545.  
  1546.         }
  1547.  
  1548.         else
  1549.  
  1550.         {
  1551.  
  1552.                 precache_model ("maps/b_batt0.bsp");
  1553.  
  1554.                 setmodel (self, "maps/b_batt0.bsp");
  1555.  
  1556.                 self.aflag = 6;
  1557.  
  1558.         }
  1559.  
  1560.         self.weapon = 4;
  1561.  
  1562.         self.netname = "cells";
  1563.  
  1564.         setsize (self, '0 0 0', '32 32 56');
  1565.  
  1566.         StartItem ();
  1567.  
  1568. };
  1569.  
  1570.  
  1571.  
  1572.  
  1573. /*QUAKED item_weapon (0 .5 .8) (0 0 0) (32 32 32) shotgun rocket spikes big
  1574.  
  1575. DO NOT USE THIS!!!! IT WILL BE REMOVED!
  1576.  
  1577. */
  1578.  
  1579.  
  1580.  
  1581. float WEAPON_SHOTGUN = 1;
  1582.  
  1583. float WEAPON_ROCKET = 2;
  1584.  
  1585. float WEAPON_SPIKES = 4;
  1586.  
  1587. float WEAPON_BIG = 8;
  1588.  
  1589. void() item_weapon =
  1590.  
  1591. {
  1592.  
  1593.         self.touch = ammo_touch;
  1594.  
  1595.  
  1596.  
  1597.         if (self.spawnflags & WEAPON_SHOTGUN)
  1598.  
  1599.         {
  1600.  
  1601.                 if (self.spawnflags & WEAPON_BIG)
  1602.  
  1603.                 {
  1604.  
  1605.                         precache_model ("maps/b_shell1.bsp");
  1606.  
  1607.                         setmodel (self, "maps/b_shell1.bsp");
  1608.  
  1609.                         self.aflag = 40;
  1610.  
  1611.                 }
  1612.  
  1613.                 else
  1614.  
  1615.                 {
  1616.  
  1617.                         precache_model ("maps/b_shell0.bsp");
  1618.  
  1619.                         setmodel (self, "maps/b_shell0.bsp");
  1620.  
  1621.                         self.aflag = 20;
  1622.  
  1623.                 }
  1624.  
  1625.                 self.weapon = 1;
  1626.  
  1627.                 self.netname = "shells";
  1628.  
  1629.         }
  1630.  
  1631.  
  1632.  
  1633.         if (self.spawnflags & WEAPON_SPIKES)
  1634.  
  1635.         {
  1636.  
  1637.                 if (self.spawnflags & WEAPON_BIG)
  1638.  
  1639.                 {
  1640.  
  1641.                         precache_model ("maps/b_nail1.bsp");
  1642.  
  1643.                         setmodel (self, "maps/b_nail1.bsp");
  1644.  
  1645.                         self.aflag = 40;
  1646.  
  1647.                 }
  1648.  
  1649.                 else
  1650.  
  1651.                 {
  1652.  
  1653.                         precache_model ("maps/b_nail0.bsp");
  1654.  
  1655.                         setmodel (self, "maps/b_nail0.bsp");
  1656.  
  1657.                         self.aflag = 20;
  1658.  
  1659.                 }
  1660.  
  1661.                 self.weapon = 2;
  1662.  
  1663.                 self.netname = "spikes";
  1664.  
  1665.         }
  1666.  
  1667.  
  1668.  
  1669.         if (self.spawnflags & WEAPON_ROCKET)
  1670.  
  1671.         {
  1672.  
  1673.                 if (self.spawnflags & WEAPON_BIG)
  1674.  
  1675.                 {
  1676.  
  1677.                         precache_model ("maps/b_rock1.bsp");
  1678.  
  1679.                         setmodel (self, "maps/b_rock1.bsp");
  1680.  
  1681.                         self.aflag = 10;
  1682.  
  1683.                 }
  1684.  
  1685.                 else
  1686.  
  1687.                 {
  1688.  
  1689.                         precache_model ("maps/b_rock0.bsp");
  1690.  
  1691.                         setmodel (self, "maps/b_rock0.bsp");
  1692.  
  1693.                         self.aflag = 5;
  1694.  
  1695.                 }
  1696.  
  1697.                 self.weapon = 3;
  1698.  
  1699.                 self.netname = "rockets";
  1700.  
  1701.         }
  1702.  
  1703.         
  1704.  
  1705.         setsize (self, '0 0 0', '32 32 56');
  1706.  
  1707.         StartItem ();
  1708.  
  1709. };
  1710.  
  1711.  
  1712.  
  1713.  
  1714.  
  1715. /*
  1716.  
  1717. ===============================================================================
  1718.  
  1719.  
  1720.  
  1721. KEYS
  1722.  
  1723.  
  1724.  
  1725. ===============================================================================
  1726.  
  1727. */
  1728.  
  1729.  
  1730.  
  1731. void() key_touch =
  1732.  
  1733. {
  1734.  
  1735. local entity    stemp;
  1736.  
  1737. local float             best;
  1738.  
  1739.  
  1740.  
  1741.         if (other.classname != "player")
  1742.  
  1743.                 return;
  1744.  
  1745.         if (other.health <= 0)
  1746.  
  1747.                 return;
  1748.  
  1749.         if (other.items & self.items)
  1750.  
  1751.                 return;
  1752.  
  1753.  
  1754.  
  1755.         sprint (other, "You got the ");
  1756.  
  1757.         sprint (other, self.netname);
  1758.  
  1759.         sprint (other,"\n");
  1760.  
  1761.  
  1762.  
  1763.         sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
  1764.  
  1765.         stuffcmd (other, "bf\n");
  1766.  
  1767.         other.items = other.items | self.items;
  1768.  
  1769.  
  1770.  
  1771.         if (!coop)
  1772.  
  1773.         {       
  1774.  
  1775.                 self.solid = SOLID_NOT;
  1776.  
  1777.                 self.model = string_null;
  1778.  
  1779.         }
  1780.  
  1781.  
  1782.  
  1783.         activator = other;
  1784.  
  1785.         SUB_UseTargets();                               // fire all targets / killtargets
  1786.  
  1787. };
  1788.  
  1789.  
  1790.  
  1791.  
  1792.  
  1793. void() key_setsounds =
  1794.  
  1795. {
  1796.  
  1797.         if (world.worldtype == 0)
  1798.  
  1799.         {
  1800.  
  1801.                 precache_sound ("misc/medkey.wav");
  1802.  
  1803.                 self.noise = "misc/medkey.wav";
  1804.  
  1805.         }
  1806.  
  1807.         if (world.worldtype == 1)
  1808.  
  1809.         {
  1810.  
  1811.                 precache_sound ("misc/runekey.wav");
  1812.  
  1813.                 self.noise = "misc/runekey.wav";
  1814.  
  1815.         }
  1816.  
  1817.         if (world.worldtype == 2)
  1818.  
  1819.         {
  1820.  
  1821.                 precache_sound2 ("misc/basekey.wav");
  1822.  
  1823.                 self.noise = "misc/basekey.wav";
  1824.  
  1825.         }
  1826.  
  1827. };
  1828.  
  1829.  
  1830. /*QUAKED item_key1 (0 .5 .8) (-16 -16 -24) (16 16 32)
  1831.  
  1832. SILVER key
  1833.  
  1834. In order for keys to work
  1835.  
  1836. you MUST set your maps
  1837.  
  1838. worldtype to one of the
  1839.  
  1840. following:
  1841.  
  1842. 0: medieval
  1843.  
  1844. 1: metal
  1845.  
  1846. 2: base
  1847.  
  1848. */
  1849.  
  1850.  
  1851.  
  1852. void() item_key1 =
  1853.  
  1854. {
  1855.  
  1856.         if (world.worldtype == 0)
  1857.  
  1858.         {
  1859.  
  1860.                 precache_model ("progs/w_s_key.mdl");
  1861.  
  1862.                 setmodel (self, "progs/w_s_key.mdl");
  1863.  
  1864.                 self.netname = "silver key";
  1865.  
  1866.         }
  1867.  
  1868.         else if (world.worldtype == 1)
  1869.  
  1870.         {
  1871.  
  1872.                 precache_model ("progs/m_s_key.mdl");
  1873.  
  1874.                 setmodel (self, "progs/m_s_key.mdl");
  1875.  
  1876.                 self.netname = "silver runekey";
  1877.  
  1878.         }
  1879.  
  1880.         else if (world.worldtype == 2)
  1881.  
  1882.         {
  1883.  
  1884.                 precache_model2 ("progs/b_s_key.mdl");
  1885.  
  1886.                 setmodel (self, "progs/b_s_key.mdl");
  1887.  
  1888.                 self.netname = "silver keycard";
  1889.  
  1890.         }
  1891.  
  1892.         key_setsounds();
  1893.  
  1894.         self.touch = key_touch;
  1895.  
  1896.         self.items = IT_KEY1;
  1897.  
  1898.         setsize (self, '-16 -16 -24', '16 16 32');
  1899.  
  1900.         StartItem ();
  1901.  
  1902. };
  1903.  
  1904.  
  1905.  
  1906. /*QUAKED item_key2 (0 .5 .8) (-16 -16 -24) (16 16 32)
  1907.  
  1908. GOLD key
  1909.  
  1910. In order for keys to work
  1911.  
  1912. you MUST set your maps
  1913.  
  1914. worldtype to one of the
  1915.  
  1916. following:
  1917.  
  1918. 0: medieval
  1919.  
  1920. 1: metal
  1921.  
  1922. 2: base
  1923.  
  1924. */
  1925.  
  1926.  
  1927.  
  1928. void() item_key2 =
  1929.  
  1930. {
  1931.  
  1932.         if (world.worldtype == 0)
  1933.  
  1934.         {
  1935.  
  1936.                 precache_model ("progs/w_g_key.mdl");
  1937.  
  1938.                 setmodel (self, "progs/w_g_key.mdl");
  1939.  
  1940.                 self.netname = "gold key";
  1941.  
  1942.         }
  1943.  
  1944.         if (world.worldtype == 1)
  1945.  
  1946.         {
  1947.  
  1948.                 precache_model ("progs/m_g_key.mdl");
  1949.  
  1950.                 setmodel (self, "progs/m_g_key.mdl");
  1951.  
  1952.                 self.netname = "gold runekey";
  1953.  
  1954.         }
  1955.  
  1956.         if (world.worldtype == 2)
  1957.  
  1958.         {
  1959.  
  1960.                 precache_model2 ("progs/b_g_key.mdl");
  1961.  
  1962.                 setmodel (self, "progs/b_g_key.mdl");
  1963.  
  1964.                 self.netname = "gold keycard";
  1965.  
  1966.         }
  1967.  
  1968.         key_setsounds();
  1969.  
  1970.         self.touch = key_touch;
  1971.  
  1972.         self.items = IT_KEY2;
  1973.  
  1974.         setsize (self, '-16 -16 -24', '16 16 32');
  1975.  
  1976.         StartItem ();
  1977.  
  1978. };
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.  
  1985.  
  1986. /*
  1987.  
  1988. ===============================================================================
  1989.  
  1990.  
  1991.  
  1992. END OF LEVEL RUNES
  1993.  
  1994.  
  1995.  
  1996. ===============================================================================
  1997.  
  1998. */
  1999.  
  2000.  
  2001.  
  2002. void() sigil_touch =
  2003.  
  2004. {
  2005.  
  2006. local entity    stemp;
  2007.  
  2008. local float             best;
  2009.  
  2010.  
  2011.  
  2012.         if (other.classname != "player")
  2013.  
  2014.                 return;
  2015.  
  2016.         if (other.health <= 0)
  2017.  
  2018.                 return;
  2019.  
  2020.  
  2021.  
  2022.         centerprint (other, "You got the rune!");
  2023.  
  2024.  
  2025.  
  2026.         sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
  2027.  
  2028.         stuffcmd (other, "bf\n");
  2029.  
  2030.         self.solid = SOLID_NOT;
  2031.  
  2032.         self.model = string_null;
  2033.  
  2034.         serverflags = serverflags | (self.spawnflags & 15);
  2035.  
  2036.         self.classname = "";            // so rune doors won't find it
  2037.  
  2038.         
  2039.  
  2040.         activator = other;
  2041.  
  2042.         SUB_UseTargets();                               // fire all targets / killtargets
  2043.  
  2044. };
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050. /*QUAKED item_sigil (0 .5 .8) (-16 -16 -24) (16 16 32) E1 E2 E3 E4
  2051.  
  2052. End of level sigil, pick up to end episode and return to jrstart.
  2053.  
  2054. */
  2055.  
  2056.  
  2057.  
  2058. void() item_sigil =
  2059.  
  2060. {
  2061.  
  2062.         if (!self.spawnflags)
  2063.  
  2064.                 objerror ("no spawnflags");
  2065.  
  2066.  
  2067.  
  2068.         precache_sound ("misc/runekey.wav");
  2069.  
  2070.         self.noise = "misc/runekey.wav";
  2071.  
  2072.  
  2073.  
  2074.         if (self.spawnflags & 1)
  2075.  
  2076.         {
  2077.  
  2078.                 precache_model ("progs/end1.mdl");
  2079.  
  2080.                 setmodel (self, "progs/end1.mdl");
  2081.  
  2082.         }
  2083.  
  2084.         if (self.spawnflags & 2)
  2085.  
  2086.         {
  2087.  
  2088.                 precache_model2 ("progs/end2.mdl");
  2089.  
  2090.                 setmodel (self, "progs/end2.mdl");
  2091.  
  2092.         }
  2093.  
  2094.         if (self.spawnflags & 4)
  2095.  
  2096.         {
  2097.  
  2098.                 precache_model2 ("progs/end3.mdl");
  2099.  
  2100.                 setmodel (self, "progs/end3.mdl");
  2101.  
  2102.         }
  2103.  
  2104.         if (self.spawnflags & 8)
  2105.  
  2106.         {
  2107.  
  2108.                 precache_model2 ("progs/end4.mdl");
  2109.  
  2110.                 setmodel (self, "progs/end4.mdl");
  2111.  
  2112.         }
  2113.  
  2114.         
  2115.  
  2116.         self.touch = sigil_touch;
  2117.  
  2118.         setsize (self, '-16 -16 -24', '16 16 32');
  2119.  
  2120.         StartItem ();
  2121.  
  2122. };
  2123.  
  2124.  
  2125. /*
  2126.  
  2127. ===============================================================================
  2128.  
  2129.  
  2130.  
  2131. POWERUPS
  2132.  
  2133.  
  2134.  
  2135. ===============================================================================
  2136.  
  2137. */
  2138.  
  2139.  
  2140.  
  2141. void() powerup_touch;
  2142.  
  2143.  
  2144.  
  2145.  
  2146.  
  2147. void() powerup_touch =
  2148.  
  2149. {
  2150.  
  2151. local entity    stemp;
  2152.  
  2153. local float             best;
  2154.  
  2155.  
  2156.  
  2157.         if (other.classname != "player")
  2158.  
  2159.                 return;
  2160.  
  2161.         if (other.health <= 0)
  2162.  
  2163.                 return;
  2164.  
  2165.  
  2166.  
  2167.         sprint (other, "You got the ");
  2168.  
  2169.         sprint (other, self.netname);
  2170.  
  2171.         sprint (other,"\n");
  2172.  
  2173.  
  2174.  
  2175.         if (deathmatch)
  2176.  
  2177.         {
  2178.  
  2179.                 self.mdl = self.model;
  2180.  
  2181.                 
  2182.  
  2183.                 if ((self.classname == "item_artifact_invulnerability") ||
  2184.  
  2185.                         (self.classname == "item_artifact_invisibility"))
  2186.  
  2187.                         self.nextthink = time + 60*5;
  2188.  
  2189.                 else
  2190.  
  2191.                         self.nextthink = time + 60;
  2192.  
  2193.                 
  2194.  
  2195.                 self.think = SUB_regen;
  2196.  
  2197.         }       
  2198.  
  2199.  
  2200.  
  2201.         sound (other, CHAN_VOICE, self.noise, 1, ATTN_NORM);
  2202.  
  2203.         stuffcmd (other, "bf\n");
  2204.  
  2205.         self.solid = SOLID_NOT;
  2206.  
  2207.         other.items = other.items | self.items;
  2208.  
  2209.         self.model = string_null;
  2210.  
  2211.  
  2212.  
  2213. // do the apropriate action
  2214.  
  2215.         if (self.classname == "item_artifact_envirosuit")
  2216.  
  2217.         {
  2218.  
  2219.                 other.rad_time = 1;
  2220.  
  2221.                 other.radsuit_finished = time + 30;
  2222.  
  2223.         }
  2224.  
  2225.         
  2226.  
  2227.         if (self.classname == "item_artifact_invulnerability")
  2228.  
  2229.         {
  2230.  
  2231.                 other.invincible_time = 1;
  2232.  
  2233.                 other.invincible_finished = time + 30;
  2234.  
  2235.         }
  2236.  
  2237.         
  2238.  
  2239.         if (self.classname == "item_artifact_invisibility")
  2240.  
  2241.         {
  2242.  
  2243.                 other.invisible_time = 1;
  2244.  
  2245.                 other.invisible_finished = time + 30;
  2246.  
  2247.         }
  2248.  
  2249.  
  2250.  
  2251.         if (self.classname == "item_artifact_super_damage")
  2252.  
  2253.         {
  2254.  
  2255.                 other.super_time = 1;
  2256.  
  2257.                 other.super_damage_finished = time + 30;
  2258.  
  2259.         }       
  2260.  
  2261.  
  2262.  
  2263.         activator = other;
  2264.  
  2265.         SUB_UseTargets();                               // fire all targets / killtargets
  2266.  
  2267. };
  2268.  
  2269.  
  2270.  
  2271.  
  2272.  
  2273.  
  2274.  
  2275. /*QUAKED item_artifact_invulnerability (0 .5 .8) (-16 -16 -24) (16 16 32)
  2276.  
  2277. Player is invulnerable for 30 seconds
  2278.  
  2279. */
  2280.  
  2281. void() item_artifact_invulnerability =
  2282.  
  2283. {
  2284.  
  2285.         self.touch = powerup_touch;
  2286.  
  2287.  
  2288.  
  2289.         precache_model ("progs/invulner.mdl");
  2290.  
  2291.         precache_sound ("items/protect.wav");
  2292.  
  2293.         precache_sound ("items/protect2.wav");
  2294.  
  2295.         precache_sound ("items/protect3.wav");
  2296.  
  2297.         self.noise = "items/protect.wav";
  2298.  
  2299.         setmodel (self, "progs/invulner.mdl");
  2300.  
  2301.         self.netname = "Pentagram of Protection";
  2302.  
  2303.         self.items = IT_INVULNERABILITY;
  2304.  
  2305.         setsize (self, '-16 -16 -24', '16 16 32');
  2306.  
  2307.         StartItem ();
  2308.  
  2309. };
  2310.  
  2311.  
  2312.  
  2313. /*QUAKED item_artifact_envirosuit (0 .5 .8) (-16 -16 -24) (16 16 32)
  2314.  
  2315. Player takes no damage from water or slime for 30 seconds
  2316.  
  2317. */
  2318.  
  2319. void() item_artifact_envirosuit =
  2320.  
  2321. {
  2322.  
  2323.         self.touch = powerup_touch;
  2324.  
  2325.  
  2326.  
  2327.         precache_model ("progs/suit.mdl");
  2328.  
  2329.         precache_sound ("items/suit.wav");
  2330.  
  2331.         precache_sound ("items/suit2.wav");
  2332.  
  2333.         self.noise = "items/suit.wav";
  2334.  
  2335.         setmodel (self, "progs/suit.mdl");
  2336.  
  2337.         self.netname = "Biosuit";
  2338.  
  2339.         self.items = IT_SUIT;
  2340.  
  2341.         setsize (self, '-16 -16 -24', '16 16 32');
  2342.  
  2343.         StartItem ();
  2344.  
  2345. };
  2346.  
  2347.  
  2348.  
  2349.  
  2350.  
  2351. /*QUAKED item_artifact_invisibility (0 .5 .8) (-16 -16 -24) (16 16 32)
  2352.  
  2353. Player is invisible for 30 seconds
  2354.  
  2355. */
  2356.  
  2357. void() item_artifact_invisibility =
  2358.  
  2359. {
  2360.  
  2361.         self.touch = powerup_touch;
  2362.  
  2363.  
  2364.  
  2365.         precache_model ("progs/invisibl.mdl");
  2366.  
  2367.         precache_sound ("items/inv1.wav");
  2368.  
  2369.         precache_sound ("items/inv2.wav");
  2370.  
  2371.         precache_sound ("items/inv3.wav");
  2372.  
  2373.         self.noise = "items/inv1.wav";
  2374.  
  2375.         setmodel (self, "progs/invisibl.mdl");
  2376.  
  2377.         self.netname = "Ring of Shadows";
  2378.  
  2379.         self.items = IT_INVISIBILITY;
  2380.  
  2381.         setsize (self, '-16 -16 -24', '16 16 32');
  2382.  
  2383.         StartItem ();
  2384.  
  2385. };
  2386.  
  2387.  
  2388.  
  2389.  
  2390.  
  2391. /*QUAKED item_artifact_super_damage (0 .5 .8) (-16 -16 -24) (16 16 32)
  2392.  
  2393. The next attack from the player will do 4x damage
  2394.  
  2395. */
  2396.  
  2397. void() item_artifact_super_damage =
  2398.  
  2399. {
  2400.  
  2401.         self.touch = powerup_touch;
  2402.  
  2403.  
  2404.  
  2405.         precache_model ("progs/quaddama.mdl");
  2406.  
  2407.         precache_sound ("items/damage.wav");
  2408.  
  2409.         precache_sound ("items/damage2.wav");
  2410.  
  2411.         precache_sound ("items/damage3.wav");
  2412.  
  2413.         self.noise = "items/damage.wav";
  2414.  
  2415.         setmodel (self, "progs/quaddama.mdl");
  2416.  
  2417.         self.netname = "Quad Damage";
  2418.  
  2419.         self.items = IT_QUAD;
  2420.  
  2421.         setsize (self, '-16 -16 -24', '16 16 32');
  2422.  
  2423.         StartItem ();
  2424.  
  2425. };
  2426.  
  2427.  
  2428.  
  2429.  
  2430.  
  2431.  
  2432.  
  2433. /*
  2434.  
  2435. ===============================================================================
  2436.  
  2437.  
  2438.  
  2439. PLAYER BACKPACKS
  2440.  
  2441.  
  2442.  
  2443. ===============================================================================
  2444.  
  2445. */
  2446.  
  2447.  
  2448.  
  2449. void() BackpackTouch =
  2450.  
  2451. {
  2452.  
  2453.         local string    s;
  2454.  
  2455.         local   float   best, old, new;
  2456.  
  2457.         local           entity  stemp;
  2458.  
  2459.         
  2460.  
  2461.         if (other.classname != "player")
  2462.  
  2463.                 return;
  2464.  
  2465.         if (other.health <= 0)
  2466.  
  2467.                 return;
  2468.  
  2469.                 
  2470.  
  2471. // if the player was using his best weapon, change up to the new one if better          
  2472.  
  2473.         stemp = self;
  2474.  
  2475.         self = other;
  2476.  
  2477.         best = W_BestWeapon();
  2478.  
  2479.         self = stemp;
  2480.  
  2481.  
  2482.  
  2483. // change weapons
  2484.  
  2485.         other.ammo_shells = other.ammo_shells + self.ammo_shells;
  2486.  
  2487.         other.ammo_nails = other.ammo_nails + self.ammo_nails;
  2488.  
  2489.         other.ammo_rockets = other.ammo_rockets + self.ammo_rockets;
  2490.  
  2491.         other.ammo_cells = other.ammo_cells + self.ammo_cells;
  2492.  
  2493.  
  2494.  
  2495.         new = self.items;
  2496.  
  2497.         if (!new)
  2498.  
  2499.                 new = other.weapon;
  2500.  
  2501.         old = other.items;
  2502.  
  2503.         other.items = other.items | new;
  2504.  
  2505.         
  2506.  
  2507.         bound_other_ammo ();
  2508.  
  2509.  
  2510.  
  2511.         sprint (other, "You get ");
  2512.  
  2513.  
  2514.  
  2515.         if (self.ammo_shells)
  2516.  
  2517.         {
  2518.  
  2519.                 s = ftos(self.ammo_shells);
  2520.  
  2521.                 sprint (other, s);
  2522.  
  2523.                 sprint (other, " shells  ");
  2524.  
  2525.         }
  2526.  
  2527.         if (self.ammo_nails)
  2528.  
  2529.         {
  2530.  
  2531.                 s = ftos(self.ammo_nails);
  2532.  
  2533.                 sprint (other, s);
  2534.  
  2535.                 sprint (other, " nails ");
  2536.  
  2537.         }
  2538.  
  2539.         if (self.ammo_rockets)
  2540.  
  2541.         {
  2542.  
  2543.                 s = ftos(self.ammo_rockets);
  2544.  
  2545.                 sprint (other, s);
  2546.  
  2547.                 sprint (other, " rockets  ");
  2548.  
  2549.         }
  2550.  
  2551.         if (self.ammo_cells)
  2552.  
  2553.         {
  2554.  
  2555.                 s = ftos(self.ammo_cells);
  2556.  
  2557.                 sprint (other, s);
  2558.  
  2559.                 sprint (other, " cells  ");
  2560.  
  2561.         }
  2562.  
  2563.         
  2564.  
  2565.         sprint (other, "\n");
  2566.  
  2567. // backpack touch sound
  2568.  
  2569.         sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM);
  2570.  
  2571.         stuffcmd (other, "bf\n");
  2572.  
  2573.  
  2574.  
  2575. // remove the backpack, change self to the player
  2576.  
  2577.         remove(self);
  2578.  
  2579.         self = other;
  2580.  
  2581.  
  2582.  
  2583. // change to the weapon
  2584.  
  2585.         if (!deathmatch)
  2586.  
  2587.                 self.weapon = new;
  2588.  
  2589.         else
  2590.  
  2591.                 Deathmatch_Weapon (old, new);
  2592.  
  2593.  
  2594.  
  2595.         W_SetCurrentAmmo ();
  2596.  
  2597. };
  2598.  
  2599.  
  2600.  
  2601. /*
  2602.  
  2603. ===============
  2604.  
  2605. DropBackpack
  2606.  
  2607. ===============
  2608.  
  2609. */
  2610.  
  2611. void() DropBackpack =
  2612.  
  2613. {
  2614.         local entity    item;
  2615.  
  2616.  
  2617.  
  2618.         if (!(self.ammo_shells + self.ammo_nails + self.ammo_rockets + self.ammo_cells))
  2619.  
  2620.                 return; // nothing in it
  2621.  
  2622.  
  2623.  
  2624.         item = spawn();
  2625.  
  2626.         item.origin = self.origin - '0 0 24';
  2627.  
  2628.         
  2629.  
  2630.         item.items = self.weapon;
  2631.  
  2632.  
  2633.  
  2634.         item.ammo_shells = self.ammo_shells;
  2635.  
  2636.         item.ammo_nails = self.ammo_nails;
  2637.  
  2638.         item.ammo_rockets = self.ammo_rockets;
  2639.  
  2640.         item.ammo_cells = self.ammo_cells;
  2641.  
  2642.  
  2643.  
  2644.         item.velocity_z = 300;
  2645.  
  2646.         item.velocity_x = -100 + (random() * 200);
  2647.  
  2648.         item.velocity_y = -100 + (random() * 200);
  2649.  
  2650.         
  2651.  
  2652.         item.flags = FL_ITEM;
  2653.  
  2654.         item.solid = SOLID_TRIGGER;
  2655.  
  2656.         item.movetype = MOVETYPE_TOSS;
  2657.  
  2658.         setmodel (item, "progs/backpack.mdl");
  2659.  
  2660.         setsize (item, '-16 -16 0', '16 16 56');
  2661.  
  2662.         item.touch = BackpackTouch;
  2663.  
  2664.         
  2665.  
  2666.         item.nextthink = time + 120;    // remove after 2 minutes
  2667.  
  2668.         item.think = SUB_Remove;
  2669.  
  2670. };
  2671.  
  2672.  
  2673.